<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<html>
<head>
    <title>全流程造数据</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/1.9.0/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/easyui/1.9.0/themes/icon.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/1.9.0/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/1.9.0/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/easyui/1.9.0/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/common/cxValidatebox.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/common/jquery.form.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/common/jquery.serializejson.js"></script>

    <script type="text/javascript">





        /**
         * 产品封闭期 禁用验证
         */
        function ccPeriodCloseEnableValidate(){
            $("#ccPeriodClose").combobox("enableValidation");
        }

        /**
         * 产品封闭期 启用验证
         */
        function ccPeriodCloseDisableValidate(){
            $("#ccPeriodClose").combobox('disableValidation');
        }

        /**
         * 产业集群企业名称 禁用验证
         */
        function tbEnterpriseNameDisableValidate(){
            $("#enterpriseName").textbox('disableValidation');
            // $("#enterpriseName").textbox({disabled:true});//加上这句，前台将不传这个字段（不知道是否需要加，还是后台判断）
        }

        /**
         * 产业集群企业名称 启用验证
         */
        function tbEnterpriseNameEnableValidate(){
            $("#enterpriseName").textbox('enableValidation');
        }


        /**
         * 初始化时，禁用验证（产品封闭期，产业集群名称）
         */
        $(function(){
            ccPeriodCloseDisableValidate();
            tbEnterpriseNameDisableValidate();
        });

        /**
         * 单击“标的类型”触发事件
         * 1.隐藏C+相关，及产业集群
         * 2.根据标类型，初始化“借款期限”，“还款方式”
         */
        $(function(){
            $("input[name='tenderType']").click(function(){

                //隐藏C+相关，及产业集群
                if($("#trCreditProductType").show() || $("#trCreditPromotion").show() || $("#trEnterpriseName").show()){
                    $("#trCreditProductType").hide();
                    $("#trCreditPromotion").hide();
                    $("#trEnterpriseName").hide();
                    tbEnterpriseNameDisableValidate();
                }

                //借款期限
                var tenderPhasesData;
                var tenderPhasesData1 = [{text:"请选择",value:"-1"},{text:"1月",value:"1"},{text:"2月",value:"2"}];
                var tenderPhasesData2 = [{text:"请选择",value:"-1"},{text:"3月",value:"3"},{text:"6月",value:"6"}];
                var tenderPhasesData3 = [{text:"请选择",value:"-1"},{text:"3月",value:"3"},{text:"6月",value:"6"},{text:"9月",value:"9"}];

                //还款方式
                var repaymentTypeData;
                var repaymentTypeData1 = [{text:"请选择",value:"-1"},{text:"等额本金",value:"1"},{text:"等额本息",value:"2"}];
                var repaymentTypeData2 = [{text:"请选择",value:"-1"},{text:"还本付息",value:"3"},{text:"等额等息",value:"6"}];
                var repaymentTypeData3 = [{text:"请选择",value:"-1"},{text:"还本付息",value:"3"},{text:"等额等息",value:"6"},{text:"等本等息",value:"7"}];

                //获取单选按钮的值
                var radiobtnVal = $("input[name='tenderType']:checked").val();
                alert(radiobtnVal);
                //清空下拉列表的值
                // $("#ccTenderPhases").combobox('clear');

                //修改借款期限的值
                if(radiobtnVal == '24'){
                    tenderPhasesData = tenderPhasesData1;
                    repaymentTypeData = repaymentTypeData1;
                }else if(radiobtnVal == '25'){
                    tenderPhasesData = tenderPhasesData2;
                    repaymentTypeData = repaymentTypeData2;
                }else if(radiobtnVal == '31'){
                    tenderPhasesData = tenderPhasesData3;
                    repaymentTypeData = repaymentTypeData3;
                }
                else if(radiobtnVal == '37'){
                    tenderPhasesData = tenderPhasesData3;
                    repaymentTypeData = repaymentTypeData3;
                    $("#creditProductType").textbox('setValue','PP');
                    $("#creditPromotion").textbox('setValue','34');
                    $("#trCreditProductType").show();
                    $("#trCreditPromotion").show();
                }
                else if(radiobtnVal == '32'){
                    tenderPhasesData = tenderPhasesData3;
                    $("#enterpriseName").textbox('setValue','金创-普通');
                    $("#trEnterpriseName").show();
                    tbEnterpriseNameEnableValidate();
                }
                //加载借款期限
                $("#ccTenderPhases").combobox({
                    data:tenderPhasesData
                });
                //加载还款方式
                $("#ccRepaymentType").combobox({
                    data:repaymentTypeData
                });

            });
        });

        /**
         * 如果产品类型是“芝麻开花”则显现封闭期
         */
        $(function(){
            $("#ccProductType").combobox({
                onChange:function(){
                    var value = $("#ccProductType").combobox('getValue');
                    if(value == '2'){
                        $("#trPeriodClose").show();
                        ccPeriodCloseEnableValidate();
                    }
                    else{
                        $("#trPeriodClose").hide();
                        ccPeriodCloseDisableValidate();
                    }
                }
            })
        })




        /**
         * form表单提交
         */
        $(function(){
            $("#fmsb").click(function(){
                if(!$("#fm").form("validate")){//如果表单验证未通过，则不提交后台
                    $.messager.alert("系统提示","信息验证未通过，请修改");
                    return ;
                }
                $("#fm").ajaxSubmit({
                    url:"${pageContext.request.contextPath}/wholeProcess/saveWholeProcess",
                    dataType:"json",
                    success:function(data){
                        if(data.status == 'success'){
                            $.messager.alert("系统提示","保存成功");
                        }
                        else{
                            $.messager.alert("系统提示","保存失败");
                        }
                    }
                });
            });
        });




    </script>
</head>
<body>
    <form id="fm" method="post" ><!-- action="${pageContext.request.contextPath}/wholeProcess/saveWholeProcess"> -->
        <table>
            <tr>
                <td>个人借款人手机号:</td>
                <td>
<%--                    <input name="borrowerPhone" class="easyui-textbox"/>--%>
                    <input name="borrowerPhone" class="easyui-textbox" data-options="required:true,validType:['mobile']"></input>
                </td>
            </tr>
            <tr>
                <td>标的类型:</td>
                <td>
                    <input  class="easyui-radiobutton" name="tenderType" value="24" label="翼车贷" labelPosition="after" checked="true" >
                    <input  class="easyui-radiobutton" name="tenderType" value="25" label="翼农贷" labelPosition="after" >
                    <input  class="easyui-radiobutton" name="tenderType" value="31" label="鑫农贷" labelPosition="after" >
                    <input  class="easyui-radiobutton" name="tenderType" value="26" label="翼商贷" labelPosition="after">
                    <input  class="easyui-radiobutton" name="tenderType" value="41" label="翼商短贷" labelPosition="after">
                    <br>
                    <input  class="easyui-radiobutton" name="tenderType" value="15" label="翼房贷活期1" labelPosition="after" labelWidth="120">
                    <input  class="easyui-radiobutton" name="tenderType" value="36" label="翼房贷活期2" labelPosition="after" labelWidth="120">
                    <input  class="easyui-radiobutton" name="tenderType" value="27" label="房抵标（定期）" labelPosition="after" labelWidth="120">
                    <br>
                    <input  class="easyui-radiobutton" name="tenderType" value="37" label="C+" labelPosition="after">
                    <input  class="easyui-radiobutton" name="tenderType" value="32" label="产业链标" labelPosition="after">
                </td>
            </tr>

            <tr>
                <td>借款标题:</td>
                <td>
<%--                    <input name="title" class="easyui-textbox"/>--%>
                    <input name="tenderTitle" class="easyui-textbox" data-options="required:true"/>
                </td>
            </tr>
            <tr>
                <td>标的金额:</td>
                <td>
<%--                    <input name="tenderAmount" class="easyui-textbox" />--%>
                    <input name="tenderAmount" class="easyui-textbox" data-options="required:true,validType:['borrowMoney']"/>
                </td>
            </tr>
            <tr>
                <td>标的利率:</td>
                <td>
<%--                    <input name="interestrate" class="easyui-textbox" />--%>
                    <input name="tentderInterestrate" class="easyui-textbox" data-options="required:true,validType:['interestrate']"/>
                </td>
            </tr>
            <tr>
                <td>还款方式:</td>
                <td>
<%--                    <select id="ccRepaymentType" class="easyui-combobox" name="repaymentType" style="width:170px;" >--%>
                    <select id="ccRepaymentType" class="easyui-combobox" name="tenderRepaymentType" style="width:170px;" data-options="required:true,validType:['selectValueRequired']">
                        <option value="-1">请选择</option>
                        <option value="1">等额本金</option>
                        <option value="2">等额本息</option>
                        <option value="3">等额等息</option>
                        <option value="7">等本等息</option>
                    </select>
                </td>
            </tr>

            <tr>
                <td>借款期限:</td>
                <td>
<%--                    <select id="ccTenderPhases" class="easyui-combobox" name="tenderPhases" style="width:170px;" >--%>
                    <select id="ccTenderPhases" class="easyui-combobox" name="tenderPhases" style="width:170px;" data-options="required:true,validType:['selectValueRequired']">
                        <option value="-1">请选择</option>
                        <option value="1">1月</option>
                        <option value="2">2月</option>
                    </select>
                </td>
            </tr>
            <tr id="trCreditProductType" style="display:none">
                <td>C+产品类型:</td>
                <td><input id="creditProductType" name="tenderCreditProductType" class="easyui-textbox" readonly=”readonly” style="width:170px"/></td>
            </tr>
            <tr id="trCreditPromotion" style="display:none">
                <td>C+增信方式:</td>
                <td><input id="creditPromotion" name="tenderCreditPromotion" class="easyui-textbox" readonly=”readonly” style="width:170px"/></td>
            </tr>
            <tr id="trEnterpriseName" style="display:none">
                <td>产业集群企业名称:</td>
                <td>
<%--                    <input id="enterpriseName" name="enterpriseName" class="easyui-textbox" style="width:170px" />--%>
                    <input id="enterpriseName" name="tenderEnterpriseName" class="easyui-textbox" style="width:170px" data-options="required:true"/>
                </td>
            </tr>
            <tr>
                <td>产品类型:</td>
                <td>
<%--                    <select id="ccProductType" class="easyui-combobox" name="productType" style="width:170px;" >--%>
                    <select id="ccProductType" class="easyui-combobox" name="productType" style="width:170px;" data-options="required:true,validType:['selectValueRequired']">
                        <option value="-1">请选择</option>
                        <option value="1">翼农计划</option>
                        <option value="2">芝麻开花</option>
                        <option value="3">私人定制</option>
                        <option value="13">翼农计划+</option>
                    </select>
                </td>
            </tr>
            <tr id="trPeriodClose" style="display:none">
                <td>产品封闭期:</td>
                <td>
<%--                    <select id="ccPeriodClose" class="easyui-combobox" name="periodClose" style="width:170px;">--%>
                    <select id="ccPeriodClose" class="easyui-combobox" name="periodClose" style="width:170px;" data-options="required:true,validType:['selectValueRequired']">
                        <option value="-1">请选择</option>
                        <option value="1">1天</option>
                        <option value="15">15天</option>
                        <option value="30">30天</option>
                        <option value="60">60天</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td></td>
                <td><br></td>
            </tr>
            <tr>
                <td></td>
                <td>
                    <a id="fmsb" class="easyui-linkbutton" iconCls="icon-ok">提交</a>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>
